Skip to content

Conversation

@uros-db
Copy link
Contributor

@uros-db uros-db commented Nov 7, 2025

What changes were proposed in this pull request?

Implement least common type (LCT) logic for GEOMETRY types, as follows:

  • LCT for GeometryType(srid_1) and GeometryType(srid_1) is: GeometryType(srid_1)
  • LCT for GeometryType(srid_1) and GeometryType(srid_2) is: GeometryType(ANY)
  • LCT for GeometryType(srid_1) and GeometryType(ANY) is: GeometryType(ANY)
  • LCT for GeometryType(ANY) and GeometryType(ANY) is: GeometryType(ANY)

In other words, the mixed SRID GEOMETRY type is the common type for all GEOMETRY types.

Why are the changes needed?

Introducing LCT and type coercion logic in the geospatial data type system.

Does this PR introduce any user-facing change?

Yes, type coercion is now supported for GeometryType.

How was this patch tested?

Added tests for geometry type coercion:

  • AnsiTypeCoercionSuite
  • TypeCoercionSuite

Added appropriate Scala suite unit tests:

  • STExpressionsSuite

Added appropriate end-to-end SQL tests:

  • st-functions

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Nov 7, 2025
Copy link
Contributor Author

@uros-db uros-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for CI.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-54244][Geo][SpatialSQL] Introduce type coercion support for GEOMETRY data types [SPARK-54244][SQL] Introduce type coercion support for GEOMETRY data types Nov 8, 2025
@dongjoon-hyun
Copy link
Member

Please resolve the conflicts, @uros-db .

@uros-db uros-db changed the title [SPARK-54244][SQL] Introduce type coercion support for GEOMETRY data types [SPARK-54244][Geo][SQL] Introduce type coercion support for GEOMETRY data types Nov 8, 2025
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Thank you, @uros-db .

@uros-db
Copy link
Contributor Author

uros-db commented Nov 8, 2025

@dongjoon-hyun All checks good, ready to merge to master & 4.1.

dongjoon-hyun pushed a commit that referenced this pull request Nov 8, 2025
…data types

### What changes were proposed in this pull request?
Implement least common type (LCT) logic for `GEOMETRY` types, as follows:

- LCT for GeometryType(`srid_1`) and GeometryType(`srid_1`) is: GeometryType(`srid_1`)
- LCT for GeometryType(`srid_1`) and GeometryType(`srid_2`) is: GeometryType(`ANY`)
- LCT for GeometryType(`srid_1`) and GeometryType(`ANY`) is: GeometryType(`ANY`)
- LCT for GeometryType(`ANY`) and GeometryType(`ANY`) is: GeometryType(`ANY`)

In other words, the mixed SRID `GEOMETRY` type is the *common type* for all GEOMETRY types.

### Why are the changes needed?
Introducing LCT and type coercion logic in the geospatial data type system.

### Does this PR introduce _any_ user-facing change?
Yes, type coercion is now supported for `GeometryType`.

### How was this patch tested?
Added tests for geometry type coercion:
- `AnsiTypeCoercionSuite`
- `TypeCoercionSuite`

Added appropriate Scala suite unit tests:
- `STExpressionsSuite`

Added appropriate end-to-end SQL tests:
- `st-functions`

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #52945 from uros-db/geo-coercion-geom.

Authored-by: Uros Bojanic <uros.bojanic@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 9b68d3c)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
@dongjoon-hyun
Copy link
Member

Merged to master/4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants